package com.wl.zk.onoffline;

import java.io.IOException;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Date;

public class TimeServer extends Thread {

    private int port = 0;

    public TimeServer(int port) {
        this.port = port;
    }

    @Override
    public void run() {
        //通过socket与client进行交流

        try {
            ServerSocket socket = new ServerSocket(port);

            while (true){
                Socket accept = socket.accept();
                OutputStream out = accept.getOutputStream();
                out.write(new Date().toString().getBytes());
            }

        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
